package com.ytg.myapi.view;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.widget.EditText;

import com.ytg.myapi.BindWay;
/**
 * Created by ximsfei on 2017/1/10.
 */

public class SkinCompatEditText extends androidx.appcompat.widget.AppCompatEditText  {

    public SkinCompatEditText(Context context) {
        this(context, null);
    }

    public SkinCompatEditText(Context context, AttributeSet attrs) {
        this(context, attrs, android.R.attr.editTextStyle);
    }

    public SkinCompatEditText(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (null != BindWay.getInstance().textBack) {
                    BindWay.getInstance().textBack.back(getId(), getTag() + "", s.toString());
                }
            }
        });
    }

}
